<template>
	<view class="content">
		<!-- form表单 -->
			<form>
				<!-- 输入框 -->
				<input type="text" name="phone" placeholder="请输入手机号" @blur="getAccount">
				<input style="margin-bottom: 25rpx;" type="text" name="pwd" @blur="getPwd" placeholder="请输入密码">
				<!-- 获取单号按钮 -->
				<label>已审核账号{{buyer_count}}个</label>
				<!-- 能刷单已审核的账单 -->
				<radio-group @change="radioChange">
					<label v-for="item in buyer_array">
						<radio :value="item.id"></radio>
						&nbsp;&nbsp;
						{{item.name}}
					</label>
				</radio-group>
				<!-- 佣金/垫付设置 -->
				<view class="code">
					<label >佣金设置</label>
					<input class="minput" type="text" name="repwd" :value="buyerInfo.priceBegin" @blur="getPriceBegin">
					<label class="minput" >~</label>
					<input class="minput" type="text" name="repwd" :value="buyerInfo.priceEnd" @blur="getPriceEnd">
				</view>
				<view class="code">
					<label >垫付设置</label>
					<input class="minput" type="text" name="repwd" :value="buyerInfo.commissionBegin" @blur="getComBegin">
					<label class="minput" >~</label>
					<input class="minput" type="text" name="repwd" :value="buyerInfo.commissionEnd" @blur="getComEnd">
				</view>
				<!-- 频率设置 -->
				<view>
					
					 <p style="color: red;">官方推荐频率{{buyerInfo.rate}}秒</p>
				</view>
				<view >
					<label >频率设置</label>
					<input class="foot_rate" type="text" name="" :value="buyerInfo.rate" @blur="getRate">
				</view>
				<!-- 获取买号 -->
				<view class="btns">
					<button class="" @click="Buy">获取买号</button>
					<button class="" @click="Verify">确认</button>
				</view>
				
				
				
				<!-- <view class="code">
					<label style="font-size: 30rpx;">佣金设置</label>
					<input class="minput" name="repwd" :value="buyerInfo.priceBegin" @blur="setPriceBegin"  maxlength="6" />
					<label class="minput" style="font-size: 40rpx;">~</label>
					<input class="minput" name="repwd" :value="buyerInfo.priceEnd" @blur="setPriceEnd"  maxlength="6" />
					</view>
				<view class="code">	
					<label style="font-size: 30rpx;">垫付设置</label>
					<input class="minput" name="repwd" :value="buyerInfo.commissionBegin" @blur="setCommissionBegin" maxlength="6" />
					<label class="minput" style="font-size: 40rpx;">~</label>
					<input class="minput" name="repwd" :value="buyerInfo.commissionEnd" @blur="setCommissionEnd" maxlength="6" />
					</view>
				 <view>
				 -->
			</form>
	</view>
</template>   

<script>
	import{
		PULL_BUYER
	}from '../../constants/index.js'
	export default{
		data(){
			return{
				buyerInfo:{
					priceBegin:1,//佣金开头
					priceEnd:999,//佣金尾数
					commissionBegin:1,//垫付开头
					commissionEnd:999,//垫付尾数
					account:'',//账号
					password:'',//密码
					buyer:0,//买主
					id:"",
					namePinyin:"",
					rate:15,//频率秒数
					
					space:"",
					platformName:"",
					platformId:"",
				},
				buyer_array:[],
				buyer_count:0
			}
		},
		// 平台标题文本
		onLoad(option) {
				this.setNavText(decodeURIComponent(option.pname));
				// 一一赋值
				this.buyerInfo.platformName=decodeURIComponent(option.pname);
				this.buyerInfo.platformId=decodeURIComponent(option.pid);
				this.buyerInfo.space=decodeURIComponent(option.prate);
				
				this.buyerInfo.id=decodeURIComponent(option.pid);
				this.buyerInfo.rate=decodeURIComponent(option.prate);
				this.buyerInfo.namePinyin=decodeURIComponent(option.pnamePinyin);
				if(typeof(this.buyerInfo.space) =="undefined" || this.buyerInfo.space<=0){
					this.buyerInfo.space=20;
					this.buyerInfo.rate=20;
				}
				
		},
		methods:{
			// 设置平台标题文本
			setNavText(content){
				wx.setNavigationBarTitle({
					title:content,
				})
			},
			// 获取手机号码与密码
			getAccount(e){
				this.buyerInfo.account=e.detail.value;
			},
			getPwd(e){
				this.buyerInfo.password=e.detail.value;
			}
			,
			// 获取佣金
			getPriceBegin(e){
				this.buyerInfo.priceBegin=e.detail.value;
			},
			getPriceEnd(e){
				this.buyerInfo.priceEnd=e.detail.value;
			},
			// 获取垫付
			getComBegin(e){
				this.buyerInfo.commissionBegin=e.detail.value;
			},
			getComEnd(e){
				this.buyerInfo.commissionEnd=e.detail.value;
			},
			// 获取频率
			getRate(e){
				this.buyerInfo.rate=e.detail.value;
			},
			
			
			
			//-------点击获取买号
			Buy(){
				// 校验手机号与密码是否正确
				if(this.buyerInfo.account.length<=0){
					return uni.showToast({
						title:"请输入手机号！"
					})
				}
				if(this.buyerInfo.password.length<=0){
					return uni.showToast({
						title:"请输入密码！"
					})
				}
				// 获取买号（发送请求）
			// 	this.$request.post(PULL_BUYER, this.buyerInfo).then(res => {
			// 		uni.showToast({
			// 			title:'获取买号'
			// 		})
			// 		if (res.code !== 0) {
			// 			/* uni.hideLoading(); */
			// 			let msg = res.msg || '获取买号失败';
			// 			return uni.showToast({
			// 				title: msg,
			// 				icon: 'none'
			// 			});
			// 		}
					
					
			// 		if(res.data.length<=0){
			// 			uni.showToast({
			// 				title: '该账号暂无已审核的买号',
			// 				icon:'none',
			// 				duration: 2000
			// 			});
			// 		}
			// 		//显示已审核个数
			// 		this.buyer_count=res.data.length;
			// 		// 获取到的买号===list集合
			// 		this.buyer_array=res.data;
			// 		uni.showToast({
			// 			title: '获取成功',
			// 			icon:'none',
			// 			duration: 3000
			// 		});
			// 	});
			// },
			
			
			this.$request.post(PULL_BUYER, this.buyerInfo).then(res => {
				console.log(123)
					// if (res.retcode !== 0) {
					// 	/* uni.hideLoading(); */
					// 	let msg = res.retmsg || '获取买号失败';
					// 	return uni.showToast({
					// 		title: msg,
					// 		icon: 'none'
					// 	});
					// }
					/* uni.hideLoading(); */
					if(res.data.length<=0){
						uni.showToast({
							title: '该账号暂无已审核的买号',
							icon:'none',
							duration: 2000
						});
					}
					this.buyer_count = res.data.length;
					this.buyer_array=res.data;
					uni.showToast({
						title: '获取成功',
						icon:'none',
						duration: 3000
					});
				});
			},
			
			//-------------点击确定按钮
			Verify(){
				// 校验是否点击过获取买号按钮
				if(this.buyer_array.length<=0){
					return uni.showToast({
						title:'请先获取买号！'
					})
				}
				// 佣金校验
				
				
				// 发送请求
				
				
			},
			//点击radio获取审核账号
			radioChange(e){
				this.buyerInfo.buyer=e.detail.value;
			}
			
		}
		
		
		
		
		
	}
</script>

<style>
	
	
	.btns button {
		color: #fff;
		background: rgb(0, 148, 255);
		border-radius: 35rpx;
	}
	.content{
		/* p */adding: 25rpx;
		padding: 5% 10% 0 10%;
	}
	input,button{
		margin-top: 40rpx;
		padding-left: 20rpx;
		font-size: 13px;
		border-radius: 20rpx;
		height: 80rpx;
		border: 1px #C0C0C0 solid;
	}
	
	.code {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
	}
	
	.code label{
		display: inline-block;
		font-size: 20rpx;
		font-weight: bold;
		color: #3B4144;
		/* text-align: left; */
		/* line-height: 10rpx; */
	}
	.code input,.foot_rate {
		border-radius: 12px;
		margin-bottom: 30rpx;
		width: 130rpx;
		height: 60rpx;
		display: inline-block;
		text-align: center;
	}
	.foot_rate{
		margin-left: 120rpx;
		margin-bottom: -24rpx;
	}
</style>
